package fnord.jovian.tango;

import java.util.Vector;

import fnord.jovian.TheBoard;
import fnord.jovian.tango.TheAssemblyLayout.TheAssemblyOrientation;

public class TheCardMenu extends TheMenu {
	
	private Vector<TheObject> _transferMenu, _attackMenu, _fullMenu;
	
	public TheCardMenu(TheBoard board) {
	    super(300, 200, board);
		_mask = null;
		TheAssemblyLayout layout = new TheAssemblyLayout(TheAssemblyOrientation.VERTICAL);
		setTheLayout(layout);
		this.addComponent(new TheButton("Transfer Money", 200, 30, new TheTransferListener()));
		this.addComponent(new TheButton("Cancel", 200, 30, new TheCancelListener()));
		_transferMenu = _objects;
		_objects = new Vector<TheObject>();
		this.addComponent(new TheButton("Attack a Group", 200, 30, new TheAttackListener()));
		this.addComponent(new TheButton("Cancel", 200, 30, new TheCancelListener()));
		_attackMenu = _objects;
		_objects = new Vector<TheObject>();
		this.addComponent(new TheButton("Attack a Group", 200, 30, new TheAttackListener()));
		this.addComponent(new TheButton("Transfer Money", 200, 30, new TheTransferListener()));
		this.addComponent(new TheButton("Cancel", 200, 30, new TheCancelListener()));
		_fullMenu = _objects;
	}
	
	public void showTransferAttack(boolean attack, boolean transfer) {
		if (transfer && attack) {
			_objects = _fullMenu;
		}
		else if (transfer) {
			_objects = _transferMenu;
		}
		else if (attack) {
			_objects = _attackMenu;
		}
		else {
			_board.cancelAction();
		}
	}
	
	private class TheCancelListener implements TheListener {
        public void doAction() {
			_board.cancelAction();
        }
	}

	private class TheAttackListener implements TheListener {
        public void doAction() {
			_board.attacking();
        }
	}
	
	private class TheTransferListener implements TheListener {
        public void doAction() {
			_board.transferringMoney();
        }
	}

}
